<template>
  <div class="td-loading">
    <div class="loading-img"></div>
    <div class="loading-text">加载中...</div>
    <div v-if="cancel" class="loading-btn">
      <TdButton @click="emit('onCancel')">取消</TdButton>
    </div>
  </div>
</template>

<script setup lang="ts">
  defineOptions({
    name: 'CsLoading',
  });

  defineProps<{
    cancel?: boolean; // 取消加载
  }>();
  const emit = defineEmits(['onCancel']);
</script>

<style scoped lang="less">
  .td-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;

    .loading-img {
      width: 100px;
      height: 100px;
      background: url('@/assets/images/common/earth_loading.gif') no-repeat;
      background-size: contain;
    }

    .loading-text {
      margin: 10px 0;
    }
  }
</style>
